/**
 * Created with JetBrains WebStorm.
 * User: renji
 * Date: 12/3/13
 * Time: 11:54 AM
 * To change this template use File | Settings | File Templates.
 */

describe('alert data controller component', function(){

    var alertDataCntrl = null;

    beforeEach(function(){
        alertDataCntrl = App.AlertDataController;
    });

    describe("Method test:",function(){

        it("showAlert method - ", function(){
            spyOn(alertDataCntrl, 'set');
            alertDataCntrl.showAlert();
            expect(alertDataCntrl.set).toHaveBeenCalledWith('showDialog', true);
        });

        it("hideAlert method - ", function(){
            spyOn(alertDataCntrl, 'set');
            alertDataCntrl.hideAlert();
            expect(alertDataCntrl.set).toHaveBeenCalledWith('showDialog', false);
        });

        it("okAction method Happy State- ", function(){
            spyOn(alertDataCntrl, 'hideAlert');

            spyOn(Ember, 'isNone').andReturn(true);

            alertDataCntrl.okAction();
            expect(Ember.isNone).toHaveBeenCalled();
            expect(alertDataCntrl.hideAlert).toHaveBeenCalled();
        });

        it("okAction method Failure State- ", function(){
            alertDataCntrl.customOkAction = function(){

            };
            spyOn(alertDataCntrl, 'hideAlert');

            spyOn(alertDataCntrl, 'customOkAction');

            spyOn(Ember, 'isNone').andReturn(false);

            alertDataCntrl.okAction();
            expect(Ember.isNone).toHaveBeenCalled();
            expect(alertDataCntrl.hideAlert).toHaveBeenCalled();
            expect(alertDataCntrl.customOkAction).toHaveBeenCalled();

        });


    });
});


describe('alert controller component', function(){

    var alertCntrl = null;

    beforeEach(function(){
        alertCntrl = App.AlertController.create({});
    });

    describe("Method test",function(){

        it("showAlertDialog method - Called with parameters and _secondButtonTitle -NOT empty", function(){
            var objAlertMsg = {message:"message", _okAction:undefined, _okButtonTitle:"Ok", _secondButtonTitle:"sdd"}

            alertCntrl.showAlertDialog(objAlertMsg.message,objAlertMsg._okAction,objAlertMsg._okButtonTitle,objAlertMsg._secondButtonTitle);
        });

        it("showAlertDialog method - Called with parameters and _secondButtonTitle -empty", function(){
            var objAlertMsg = {message:"message", _okAction:undefined, _okButtonTitle:"Ok", _secondButtonTitle:""}

            alertCntrl.showAlertDialog(objAlertMsg.message,objAlertMsg._okAction,objAlertMsg._okButtonTitle,objAlertMsg._secondButtonTitle);
        });

    });

    describe("showError method test", function(){

        it("showError method - ", function(){

            spyOn(alertCntrl, 'showAlertDialog');
            alertCntrl.showError();
            expect(alertCntrl.showAlertDialog).toHaveBeenCalled();
        });
    });

    describe("showError method test", function(){

        it("showError method - ", function(){

            var objAlertMsg = {message:undefined, _okAction:undefined, _okButtonTitle:undefined, _secondButtonTitle:undefined,_secondButtonAction:undefined }

            spyOn(alertCntrl, 'showAlertDialog');

            alertCntrl.showAlert(objAlertMsg);

            expect(alertCntrl.showAlertDialog).toHaveBeenCalledWith(objAlertMsg.message,objAlertMsg._okAction,objAlertMsg._okButtonTitle,objAlertMsg._secondButtonTitle,objAlertMsg._secondButtonAction);
        });
    });
});